/**
* Copyright 2023 PYSTOR DBS, Nanjing Pengyun Network Technology Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/ 

package py.coordinator.task;

import py.archive.segment.SegId;
import py.common.DelayRequest;


public class CommitLogContext extends DelayRequest {

  private final Long volumeId;
  private final SegId segId;


  public CommitLogContext(Long volumeId, SegId segId, long delay) {
    super(delay);
    this.volumeId = volumeId;
    this.segId = segId;
  }

  public Long getVolumeId() {
    return volumeId;
  }

  public SegId getSegId() {
    return segId;
  }

  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (!(o instanceof CommitLogContext)) {
      return false;
    }

    CommitLogContext that = (CommitLogContext) o;

    if (volumeId != null ? !volumeId.equals(that.volumeId) : that.volumeId != null) {
      return false;
    }
    if (segId != null ? !segId.equals(that.segId) : that.segId != null) {
      return false;
    }
    return true;
  }

  @Override
  public int hashCode() {
    int result = volumeId != null ? volumeId.hashCode() : 0;
    result = 31 * result + (segId != null ? segId.hashCode() : 0);
    return result;
  }

  @Override
  public String toString() {
    return "CommitLogContext{" + "volumeId=" + volumeId + ", segId=" + segId
        + '}';
  }
}
